// Decompiled by DJ v3.9.9.91 Copyright 2005 Atanas Neshkov  Date: 2010-6-14 20:35:35
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   CommonProperties.java

package com.brother.util;

import com.brother.database.DataBase;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.apache.log4j.Logger;

public class CommonProperties
{

    public CommonProperties()
    {
    }

    public static String getEmailFooter()
    {
        return props.getProperty("mail.footer");
    }
    
    public static String getValue(String key){
    	try{
    		return props.getProperty(key);
    	}catch(Exception e){
    		Logger.getLogger(CommonProperties.class).error(e);
    	}
        return "";
    }

    public static long getLostSignalTime()
    {
    	try{
    		return Long.parseLong(props.getProperty("lost.signal.time"));
	    }catch(Exception e){
			Logger.getLogger(CommonProperties.class).error(e);
		}
        return 0L;
    }

    public static String getSystemHostName()
    {
    	try{
    		return props.getProperty("system.host.name");
    	}catch(Exception e){
    		Logger.getLogger(CommonProperties.class).error(e);
    	}
        
        return "";
    }

    public static String getGoogleMapKey(String key)
    {
    	try{
    		return props.getProperty(key);
	    }catch(Exception e){
			Logger.getLogger(CommonProperties.class).error(e);
		}
        return "";
    }

    public static int getTruncateInterval()
    {
    	try{
    		return Integer.parseInt(props.getProperty("truncate.interval"));
	    }catch(Exception e){
			Logger.getLogger(CommonProperties.class).error(e);
		}
        return 1000;
    }

    public static int getServerOutputInterval()
    {
    	try{
    		return Integer.parseInt(props.getProperty("server.output.interval"));
	    }catch(Exception e){
			Logger.getLogger(CommonProperties.class).error(e);
		}
        return 1000;
    }

    public static int getFirstServerOutputTime()
    {
    	try{
    		return Integer.parseInt(props.getProperty("server.output.interval"));
	    }catch(Exception e){
			Logger.getLogger(CommonProperties.class).error(e);
		}
        return 1000;
    }
    
    public static String getGeoHost(){
    	try{
    		return props.getProperty("server.geo.host");
	    }catch(Exception e){
			Logger.getLogger(CommonProperties.class).error("",e);
		}
        return "http://locahost:8080/";
    }

    private static Properties props;

    static 
    {
        InputStream in;
        props = null;
        if(props == null){
           
	        in = CommonProperties.class.getResourceAsStream("/common.properties");
	        props = new Properties();
	        try
	        {
	            props.load(in);
	        }
	        catch(IOException ioexception)
	        {
	        	ioexception.printStackTrace();
	        }finally{
	        	if(in != null)
		            try
		            {
		                in.close();
		            }
		            catch(IOException ioexception2) { }
	        }
        }
    }

	public static int getMileageUpdateTime() {
		try{
    		return Integer.parseInt(props.getProperty("mileage.update.interval"));
	    }catch(Exception e){
			Logger.getLogger(CommonProperties.class).error("", e);
		}
		return 360;
	}
	
	public static String getHostByCountry(String country){
		try{
    		return props.getProperty("geomap."+country);
	    }catch(Exception e){
			Logger.getLogger(CommonProperties.class).error("", e);
		}
	    return  "";
	}
	
	public static String getReportTableSchema(){
		// table.report.create.schema
		try{
    		return props.getProperty("table.report.create.schema");
	    }catch(Exception e){
			Logger.getLogger(CommonProperties.class).error("", e);
		}
	    return  "";
	}
	
	public static String getBackupPath() {
		// table.report.create.schema
		try{
    		return props.getProperty("backup.path");
	    }catch(Exception e){
			Logger.getLogger(CommonProperties.class).error("", e);
		}
	    return  "";
	}
}